package com.xiaol.ray.atomikosdemo.controller;

import com.xiaol.ray.atomikosdemo.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * User: Ray.Shaw <p />
 * Time: 2019/10/25 10:39  <p />
 * Version: V1.0  <p />
 * Description:  <p />
 */
@Slf4j
@RequestMapping(path = "test", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RestController
public class TestController {
    @Resource
    private RedisUtil redisUtil;

    @RequestMapping("setRedis")
    public boolean setRedis(String key, String value){
        log.info("setRedis:[key:{}, value:{}]", key, value);
        return redisUtil.set(key,value);
    }

    @RequestMapping("get")
    public Object redisget(String key){
        return redisUtil.get(key);
    }

    @RequestMapping("t/{id}")
    public Object test(@PathVariable("id") String id){
        return "this is " + id;
    }
}
